﻿using System.Collections.Generic;

namespace PhantomChainsAnalyser.Model
{
    public class IntervalDivider
    {
        public List<double> Borders = null;
        public List<int> Values = null;

        public void Divide(Sampling sampling)
        {
            Borders = new List<double>();
            Values = new List<int>();
            int IntervalCount = 20;
            Sampling Ranged = sampling.RangedSampling();
            double min = Ranged.Min();
            double max = Ranged.Max();
            double step = (max - min) / IntervalCount;
            int position = 0;
            Borders.Add(min);
            for (int i = 0; i < IntervalCount; i++)
            {
                Borders.Add(Borders[i] + step);
                Values.Add(0);
                while ((position < Ranged.GetVolume()) && ((Ranged[position] <= Borders[i + 1]) || (i == IntervalCount - 1)))
                {
                    Values[i]++;
                    position++;
                }
            }
        }
    }
}